********************************************************************************
* Exporting representativeness table for multi-country COVID paper (BGD3 sample)
* last updated: 2020-10-22
* Salim Benhachmi
********************************************************************************

use "$da/BGD3", clear

local variables hhsize female_respondent edu hh_inc

foreach var of local variables {
		
	sum `var' if covid_sample == 1
	loc mean_`var'_samp = round(`r(mean)', 0.01)
}

svyset cluster2 [pw=hh_weight_covid], singleunit(scaled)

foreach var of local variables {
		
	svy: mean `var' if covid_sample == 1
	matrix b = r(table)
	loc mean_`var'_samp_wt = round(b[1,1], 0.01)
}

svyset cluster [pw=hh_weight], singleunit(scaled)

foreach var of local variables {
		
	svy: mean `var'
	matrix b = r(table)
	loc mean_`var'_pop = round(b[1,1], 0.01)
}

clear
set obs 5

gen sample_avg = .
gen sample_avg_weight = .
gen population_avg = .

replace sample_avg = . in 1
replace sample_avg_weight = . in 2
replace population_avg = . in 1

replace sample_avg = `mean_hhsize_samp' in 2
replace sample_avg_weight = `mean_hhsize_samp_wt' in 2
replace population_avg = `mean_hhsize_pop' in 2

replace sample_avg = `mean_female_respondent_samp' in 3
replace sample_avg_weight = `mean_female_respondent_samp_wt' in 3
replace population_avg = `mean_female_respondent_pop' in 3

replace sample_avg = `mean_edu_samp' in 4
replace sample_avg_weight = `mean_edu_samp_wt' in 4
replace population_avg = `mean_edu_pop' in 4

replace sample_avg = `mean_hh_inc_samp' in 5
replace sample_avg_weight = `mean_hh_inc_samp_wt' in 5
replace population_avg = `mean_hh_inc_pop' in 5

gen national_avg = .
replace national_avg = 0.73 in 1
replace national_avg = 4.06 in 2
replace national_avg = 0.50 in 3
replace national_avg = 0.20 in 4
replace national_avg = 510 in 5

export excel using "$dtab/Representativeness Table.xlsx", sheetmodify cell(C18)

********************************************************************************
